<?php
class goods extends PHPUnit_Framework_TestCase
{
    function setUp() {
        $this->_rpc = include 'rpc.php';
    }
    /**
     * undocumented function
     *
     * @return void
     * @author 
     **/
    public function testgoo()
    {
        $query_params =array (
  'item_lists' => '{"item":[{"name":"\\u6d4b\\u8bd5\\u5546\\u54c11","title":"\\u6d4b\\u8bd5\\u5546\\u54c11","item_code":"test1","remark":"","type":"NORMAL","is_sku":"1","gross_weight":"10.000","net_weight":"10.000","tare_weight":"","is_friable":"","is_dangerous":"","pricing_cat":"","package_material":"","price":"","support_batch":"\\u5426","support_expire_date":"\\u5426","expire_date":"2015-07-16","support_barcode":"0","barcode":"t00001","support_antifake":"\\u5426","unit":"","package_spec":"","ename":"","brand":"","batch_no":"","goods_cat":"","color":"","property":""},{"name":"\\u9650\\u91cf\\u7248\\u8fd0\\u52a8\\u886b","title":"\\u9650\\u91cf\\u7248\\u8fd0\\u52a8\\u886b","item_code":"test7","remark":"","type":"NORMAL","is_sku":"1","gross_weight":"20.000","net_weight":"20.000","tare_weight":"","is_friable":"","is_dangerous":"","pricing_cat":"","package_material":"","price":"","support_batch":"\\u5426","support_expire_date":"\\u5426","expire_date":"2015-07-16","support_barcode":"0","barcode":"code7","support_antifake":"\\u5426","unit":"","package_spec":"","ename":"","brand":"","batch_no":"","goods_cat":"","color":"","property":""},{"name":"\\u9650\\u91cf\\u7248\\u8fd0\\u52a8\\u886b","title":"\\u9650\\u91cf\\u7248\\u8fd0\\u52a8\\u886b","item_code":"test8","remark":"","type":"NORMAL","is_sku":"1","gross_weight":"10.000","net_weight":"10.000","tare_weight":"","is_friable":"","is_dangerous":"","pricing_cat":"","package_material":"","price":"","support_batch":"\\u5426","support_expire_date":"\\u5426","expire_date":"2015-07-16","support_barcode":"0","barcode":"code8","support_antifake":"\\u5426","unit":"","package_spec":"","ename":"","brand":"","batch_no":"","goods_cat":"","color":"","property":"\\u7ea2;XXL"}]}',
  'uniqid' => '2554e46ed51041fd90b672eb6317b0b4',
  'to_node_id' => '1583762438',
  'app_id' => 'ecos.ome',
  'method' => 'store.wms.item.add',
  'date' => '2015-07-16 13:58:41',
  'callback_url' => 'http://192.168.41.17/erpbugfix/index.php/callback/id/ad7d76ac83a174e274812f5266176cdf-1437026321/app_id/ome',
  'format' => 'json',
  'certi_id' => '1271706832',
  'v' => '1.1',
  'from_node_id' => '1835383836',
  'task' => 'ad7d76ac83a174e274812f5266176cdf',
  'sign' => 'B7C02A48E42511A751BECDF4602BDFE4',
);
        $core_http = kernel::single('base_httpclient');
        $response = $core_http->set_timeout(5)->post('http://rpc.ex-sandbox.com',$query_params,$headers);
        var_dump($response);exit;
    }


    /**
    * 商品
    */
    public function testgoods(){

        #商品添加
        $sdf = array(
            array(
                'bn' => 'pbn1',
                'product_id' => '1',
                'name' => 'pbn1商品名称',
                'barcode' => 'pbn1-barcode',
                'unit' => '件',
                'weight' => '3G',
                'price' => '299',
                'package_spec' => '',
                'ename' => 'en',
                'brand' => '',
                'goods_cat' => '通用商品类型',
                'color' => '',
                'property' => '',
                'memo' => 'memo',
            ),
            array(
                'bn' => 'pbn2',
                'product_id' => '2',
                'name' => 'pbn2商品名称',
                'barcode' => 'pbn1-barcode',
                'unit' => '件',
                'weight' => '3G',
                'price' => '299',
                'package_spec' => '',
                'ename' => 'en',
                'brand' => '',
                'goods_cat' => '通用商品类型',
                'color' => '',
                'property' => '',
                'memo' => 'memo',
            )
        );
        $callback = array (
  0 => 'middleware_wms_matrixwms_request_goods',
  1 => 'goods_add_callback',
  2 => 
  array (
    'log_id' => '91e59a51f74426f17a8bb667a2b40e3b',
    'userCallback_class' => NULL,
    'userCallback_method' => NULL,
    'userCallback_params' => NULL,
    'callback_params' => NULL,
  ),
);
        $params = array (
  'items'=>'[{"product_name":"\u7537\u6b3e\u9ed1\u8272\u7537\u76ae\u978b-1005R","product_bn":"1005RW-060","barcode":"885641752675"}]',
  'uniqid' => 'f1e652ef6d16af79938cb68d3db0ac96',
  'node_id' => 'TBL',
  'to_node_id' => 'TBL',
            'method'=>'store.wms.item.add',
);
        $mode = 'false';
        $time_out=5;
         $callback_class = $callback[0];
        $callback_method = $callback[1];
        $method = 'store.wms.item.add';
        $callback_params = (isset($callback[2])&&$callback[2])?$callback[2]:array();
       $re =  kernel::single('rpc_caller')->conn('fsockopen')->set_timeout($time_out)->call('http://ytznewbalance.ftp.taoex.com/src/background.php',$method,$params);
       var_dump($re);
       $re = json_decode($re,true);
       error_log(var_export($re,1),3,__FILE__.'.log');
    }

}
